create table ustore_unique_deferrable
(
    c1 int,
    c2 int,
    constraint ustore_unique_deferrable_c2_key unique (c2) deferrable
) with (storage_type = 'ustore');
insert into ustore_unique_deferrable values(1, 1);

-- 约束生效
insert into ustore_unique_deferrable values(2, 1);

-- 去除列约束正常插入
alter table ustore_unique_deferrable drop constraint if exists ustore_unique_deferrable_c2_key;
insert into ustore_unique_deferrable values(2, 1);

-- 有重复数据时无法添加列约束
alter table ustore_unique_deferrable add constraint ustore_unique_deferrable_c2_key unique (c2) deferrable;

-- 删除重复数据添加列约束成功
delete from ustore_unique_deferrable where c1 = 2;
alter table ustore_unique_deferrable add constraint ustore_unique_deferrable_c2_key unique (c2) deferrable;

begin;
set constraints all deferred;
insert into ustore_unique_deferrable values(1, 1);
end;

begin;
set constraints all immediate;
insert into ustore_unique_deferrable values(1, 1);
end;

begin;
set constraints all deferred;
insert into ustore_unique_deferrable values(1, 1);
set constraints all immediate;
end;

drop table ustore_unique_deferrable;